/**

 */

var pageXHR;
var contentId;
var embed;

function handlePageResult(doc)
{
	var fixURL1 = doc.split('content_id\", \"');
	var fixURL2 = fixURL1[1].split('\")');
	contentId = fixURL2[0];
	
	var fixURL3 = doc.split('embed/');
	var fixURL4 = fixURL3[1].split('\"');
	embed = fixURL4[0];
	
	var dctk = connected.toolkit;
	connected.debug.print("content_id = "+contentId);
	connected.debug.print("eid = "+embed);
	startMetaRequest();
	showPlaybackPopup();
	
}

function startPageRequest()
{
    pageXHR = new XMLHttpRequest();
    pageXHR.onreadystatechange = onPageXHRStateChange;
    pageXHR.open("GET", pageUrl, true);
	pageXHR.overrideMimeType('text/xml');
    pageXHR.send(null);
}

function onPageXHRStateChange()
{
    if (pageXHR.readyState == 4)
    {
        if (pageXHR.status == 200)
        {
            //findMedia(pageXHR.responseXML);
			handlePageResult(pageXHR.responseText);
        }
    }
}